<template>
  <div>
    <h2>欢迎光临，大怨种</h2>
    <table>
      <tr>苹果{{danjia}}￥/斤，折扣8折</tr>
      <tr>输入你想要购买的斤数<input type="text" v-model.number="num"></tr>
      <button>结算</button><br>
      <div>总价：{{total()}}元 折后价：{{zhekou()}}元 省了：{{save()}}元</div>
    </table>

  </div>
</template>

<script>
export default {
  data(){
    return{
      danjia:10,
      num:0
    }
  },
  methods:{
    total(){
      return this.num*this.danjia
    },
    zhekou(){
      return this.num*this.danjia*0.8
    },
    save(){
      return this.num*this.danjia*0.2
    }
  }
}
</script>

<style>

</style>